package com.xsh.controller;

import com.xsh.pojo.Role;
import com.xsh.service.RoleService;
import com.xsh.utils.GetClassUtils;
import com.xsh.utils.R;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@CrossOrigin("http://localhost:8082")
public class RolesController {

    private RoleService roleService = (RoleService) GetClassUtils.getClass("roleServiceImpl");

    @GetMapping("/roles")
    @ResponseBody
    public R getRoles(){
        List<Role> roles = roleService.findAll();
        return R.ok().put("roles", roles);
    }
}
